@echo off
REM 设置当前窗口的标题
title AI Publisher Starter

echo ===================================================
echo =       AI Article Publisher Startup Script       =
echo ===================================================
echo.

REM 启动后端服务器
echo [1/4] Starting backend server...
cd backend
start "Backend Server (Node.js)" cmd /k "node server.js"
cd ..
echo      Backend server process initiated.
echo.

REM 启动前端开发服务器
echo [2/4] Starting frontend server...
cd frontend
start "Frontend Server (Vite)" cmd /k "npm run dev"
cd ..
echo      Frontend server process initiated.
echo.

REM 等待服务器初始化
echo [3/4] Waiting 8 seconds for servers to initialize...
timeout /t 8 /nobreak > nul
echo      Wait complete.
echo.

REM 在默认浏览器中打开前端页面
echo [4/4] Opening application in your default browser...
start http://localhost:5173
echo      Browser launch command sent.
echo.

echo ===================================================
echo = All services started successfully!              =
echo = You can now close this script window.           =
echo ===================================================
echo.

REM 暂停，以便用户可以看到消息
pause